#ifndef ASSETSYSTEM_H
#define ASSETSYSTEM_H

#include <export.h>
#include <map>
#include <asset/asset.h>
#include <asset/assetreader.h>
#include <vector>

typedef std::map<std::string, ceAsset*>	ceAssetMap;

class ceEngine;
class CE_API ceAssetSystem
{
private:
	ceEngine* _engine;
	std::map<ceAssetTypeID, ceAssetMap>	_assets;
	std::vector<iAssetReader*>					_readers;
public:
	ceAssetSystem(ceEngine* engine);

	ceAsset* AddAsset (ceAsset* asset);
	ceAsset* GetAsset (ceAssetTypeID typeID, const ceAssetLocator& locator);
  ceRef<ceAsset> LoadAsset (ceAssetTypeID typeID, const ceAssetLocator& locator);

	void RegisterAssetReader (iAssetReader* reader);
	void UnregisterAssetReader (iAssetReader* reader);

	template<typename T>
	T* GetAsset (const ceAssetLocator& locator)
	{
		return static_cast<T*>(GetAsset (T::AssetTypeID, locator));
	}

	template<typename T>
	ceRef<T> LoadAsset (const ceAssetLocator& locator)
	{
		return static_cast<T*>(LoadAsset (T::AssetTypeID, locator));
	}
};


#endif // ASSETSYSTEM_H
